home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / Portable Patmos / usr / include / sys / exec.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-08  |  7.6 KB  |  194 lines  |  [TEXT/R*ch]

  1. /*-
  2.  * Copyright (c) 1982, 1986 The Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  * 3. All advertising materials mentioning features or use of this software
  14.  *    must display the following acknowledgement:
  15.  *    This product includes software developed by the University of
  16.  *    California, Berkeley and its contributors.
  17.  * 4. Neither the name of the University nor the names of its contributors
  18.  *    may be used to endorse or promote products derived from this software
  19.  *    without specific prior written permission.
  20.  *
  21.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31.  * SUCH DAMAGE.
  32.  *
  33.  *    from: @(#)exec.h    7.5 (Berkeley) 2/15/91
  34.  *    $Id: exec.h,v 1.20 1993/10/02 20:08:19 pk Exp $
  35.  */
  36.  
  37. #ifndef    _SYS_EXEC_H_
  38. #define    _SYS_EXEC_H_
  39.  
  40. #include    <sys/param.h>
  41. #include    <sys/cdefs.h>
  42.  
  43. /*
  44.  * Header prepended to each a.out file.
  45.  * only manipulate the a_midmag field via the
  46.  * N_SETMAGIC/N_GET{MAGIC,MID,FLAG} macros in a.out.h
  47.  */
  48. struct exec {
  49.     unsigned long    a_midmag;    /* htonl(flags<<26 | mid<<16 | magic) */
  50.     unsigned long    a_text;        /* text segment size */
  51.     unsigned long    a_data;        /* initialized data size */
  52.     unsigned long    a_bss;        /* uninitialized data size */
  53.     unsigned long    a_syms;        /* symbol table size */
  54.     unsigned long    a_entry;    /* entry point */
  55.     unsigned long    a_trsize;    /* text relocation size */
  56.     unsigned long    a_drsize;    /* data relocation size */
  57. };
  58.  
  59. /* a_magic */
  60. #define    OMAGIC        0407    /* old impure format */
  61. #define    NMAGIC        0410    /* read-only text */
  62. #define    ZMAGIC        0413    /* demand load format */
  63. #define QMAGIC        0314    /* "compact" demand load format -- DEPRICATE */
  64.  
  65. /*
  66.  * a_mid - keep sorted in numerical order for sanity's sake
  67.  * ensure that: 0 < mid < 0x3ff
  68.  */
  69. #define MID_ZERO    0    /* unknown - implementation dependent */
  70. #define MID_SUN010    1    /* sun 68010/68020 binary */
  71. #define MID_SUN020    2    /* sun 68020-only binary */
  72. #define MID_PC386    100    /* 386 PC binary. (so quoth BFD) */
  73. #define MID_HP200    200    /* hp200 (68010) BSD binary */
  74. #define MID_I386    134    /* i386 BSD binary */
  75. #define MID_M68K    135    /* m68k BSD binary with 8K page sizes */
  76. #define MID_M68K4K    136    /* m68k BSD binary with 4K page sizes */
  77. #define MID_NS32532    137    /* ns32532 */
  78. #define MID_SPARC    138    /* sparc */
  79. #define MID_HP300    300    /* hp300 (68020+68881) BSD binary */
  80. #define MID_HPUX    0x20C    /* hp200/300 HP-UX binary */
  81. #define    MID_HPUX800     0x20B   /* hp800 HP-UX binary */
  82.  
  83. /*
  84.  * a_flags
  85.  */
  86. #define EX_DYNAMIC    0x20    /* a.out contains run-time link-edit info */
  87.  
  88.  
  89. /*
  90.  * it's nearly impossible to find out where a process's args are without
  91.  * a hint.  4.4 actually puts pointers in the process address space,
  92.  * above the stack.  this is reasonable, and also allows the process to
  93.  * set its ps-visible arguments easily.
  94.  *
  95.  * PS_STRINGS defines the location of a process's ps_strings structure.
  96.  */
  97.  
  98. struct ps_strings {
  99.   char *ps_argvstr;       /* the argv strings */
  100.   int  ps_nargvstr;       /* number of argv strings */
  101.   char *ps_envstr;        /* the environment strings */
  102.   int  ps_nenvstr;        /* number of environment strings */
  103. };
  104. #define PS_STRINGS \
  105.         ((struct ps_strings *)(USRSTACK - sizeof(struct ps_strings)))
  106.  
  107. /*
  108.  * the following structures allow execve() to put together processes
  109.  * in a more extensible and cleaner way.
  110.  *
  111.  * the exec_package struct defines an executable being execve()'d.
  112.  * it contains the header, the vmspace-building commands, the vnode
  113.  * information, and the arguments associated with the newly-execve'd
  114.  * process.
  115.  *
  116.  * the exec_vmcmd struct defines a command description to be used
  117.  * in creating the new process's vmspace.
  118.  */
  119.  
  120. struct proc;
  121. struct exec_package;
  122.  
  123. typedef int (*exec_makecmds_fcn) __P((struct proc *, struct exec_package *));
  124. typedef void (*exec_setup_fcn) __P((struct proc *, struct exec_package *));
  125.  
  126. struct execsw {
  127.     exec_makecmds_fcn    check;    /* function to check exec format */
  128. };
  129.  
  130. struct exec_package {
  131.   struct exec *ep_execp;      /* file's exec header */
  132.   exec_setup_fcn ep_setup;    /* special setup function for exec type */
  133.   struct exec_vmcmd *ep_vcp;  /* exec_vmcmds used to build the vmspace */
  134.   struct vnode *ep_vp;        /* executable's vnode */
  135.   struct vattr *ep_vap;       /* executable's attributes */
  136.   unsigned long ep_taddr;     /* process's text address */
  137.   unsigned long ep_tsize;     /* size of process's text */
  138.   unsigned long ep_daddr;     /* process's data(+bss) address */
  139.   unsigned long ep_dsize;     /* size of process's data(+bss) */
  140.   unsigned long ep_maxsaddr;  /* process's max stack address ("top") */
  141.   unsigned long ep_minsaddr;  /* process's min stack address ("bottom") */
  142.   unsigned long ep_ssize;     /* size of process's stack */
  143.   unsigned long ep_entry;     /* process's entry point */
  144. };
  145.  
  146. struct exec_vmcmd {
  147.   struct exec_vmcmd *ev_next;   /* next command on the chain */
  148.   int                (*ev_proc) __P((struct proc *p, struct exec_vmcmd *cmd));
  149.                 /* procedure to run for region of vmspace */
  150.   unsigned long     ev_len;     /* length of the segment to map */
  151.   unsigned long     ev_addr;    /* address in the vmspace to place it at */
  152.   struct vnode      *ev_vp;     /* vnode pointer for the file w/the data */
  153.   unsigned long     ev_offset;  /* offset in the file for the data */
  154.   unsigned          ev_prot;    /* protections for segment */
  155. };
  156.  
  157. #ifdef KERNEL
  158. /*
  159.  * funtions used either by execve() or the various cpu-dependent execve()
  160.  * hooks.
  161.  */
  162. struct exec_vmcmd *new_vmcmd    __P((
  163.      int (*proc) __P((struct proc *p, struct exec_vmcmd *)),
  164.      unsigned long len, unsigned long addr, struct vnode *vp,
  165.      unsigned long offset, unsigned long prot));
  166. void    kill_vmcmd        __P((struct exec_vmcmd **));
  167. int    exec_makecmds        __P((struct proc *, struct exec_package *));
  168. int    exec_runcmds        __P((struct proc *, struct exec_package *));
  169. int    vmcmd_map_pagedvn    __P((struct proc *, struct exec_vmcmd *));
  170. #ifdef notyet
  171. int    vmcmd_map_readvn    __P((struct proc *, struct exec_vmcmd *));
  172. #endif
  173. int    vmcmd_map_zero        __P((struct proc *, struct exec_vmcmd *));
  174.  
  175. /*
  176.  * Exec function switch:
  177.  *
  178.  * Note that each makecmds function is responsible for loading the
  179.  * exec package with the necessary functions for any exec-type-specific
  180.  * handling.
  181.  *
  182.  * Also note that a.out format is "standard".  other formats should have
  183.  * prototypes here for their makecmds functions, but those prototypes
  184.  * and the table entries in kern_exec.c should be #ifdef'd.
  185.  */
  186. extern    struct execsw        execsw[];
  187. extern    int            nexecs;
  188. int    exec_aout_makecmds    __P((struct proc *, struct exec_package *));
  189.  
  190. #endif
  191.  
  192. #endif /* !_SYS_EXEC_H_ */
  193.  
  194.